import jwt from 'jsonwebtoken';

const SECRET_KEY = process.env.JTW_SECRET || 'your-secret-key';

export function signToken(payload: object, expiresIn: string | number = '1h'): string {
    return jwt.sign(payload, SECRET_KEY, { expiresIn });
}

export function verifyToken(token: string): any {
    try {
        return jwt.verify(token, SECRET_KEY);
    } catch (error) {
        return null;
    }
}


